package org.domeos.framework.api.controller.alarm;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.domeos.basemodel.HttpResponseTemp;
import org.domeos.framework.api.controller.ApiController;
import org.domeos.framework.api.service.alarm.AlarmSenderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/api")
@Api("报警相关api")
public class AlarmSenderController extends ApiController {

    @Autowired
    AlarmSenderService alarmSenderService;

    @ApiOperation(value="短信发送",notes="根据短信内容发送报警事件")
    @ResponseBody
    @RequestMapping(value = "/alarm/send/sms", method = RequestMethod.POST)
    public HttpResponseTemp<?> SendAlarmSMS(@RequestParam("tos") String tos,
                                            @RequestParam("content") String content,
                                            @RequestParam("subject") String subject,
                                            @RequestParam(value = "sender", required = false) String sender) {
        return alarmSenderService.sendSMS(tos, content, subject, sender);
    }

    @ApiOperation(value="邮件发送",notes="根据邮件内容发送报警事件")
    @ResponseBody
    @RequestMapping(value = "/alarm/send/mail", method = RequestMethod.POST)
    public HttpResponseTemp<?> SendAlarmMail(@RequestParam("tos") String tos,
                                             @RequestParam("content") String content,
                                             @RequestParam("subject") String subject,
                                             @RequestParam(value = "sender", required = false) String sender) {
        return alarmSenderService.sendMail(tos, content, subject, sender);
    }

    @ApiOperation(value="微信发送",notes="根据微信内容发送报警事件")
    @ResponseBody
    @RequestMapping(value = "/alarm/send/wechat", method = RequestMethod.POST)
    public HttpResponseTemp<?> SendAlarmWechat(@RequestParam("tos") String tos,
                                               @RequestParam("content") String content,
                                               @RequestParam("subject") String subject,
                                               @RequestParam(value = "sender", required = false) String sender) {
        return alarmSenderService.sendWechat(tos, content, subject, sender);
    }
}